package dto

import "github.com/kataras/iris/v12"

type ApiResponse struct {
	Status int         `json:"status"`
	Msg    interface{} `json:"msg"`
	Data   interface{} `json:"data"`
}

func ResponseSuccess(data interface{}) ApiResponse {
	return ApiResponse{
		Status: iris.StatusOK,
		Msg:    "操作成功",
		Data:   data}
}

func ResponseNotFound() ApiResponse {
	return ApiResponse{
		Status: iris.StatusNotFound,
		Msg:    "资源未发现，操作失败"}
}

func ResponseInternalServerError() ApiResponse {
	return ApiResponse{
		Status: iris.StatusInternalServerError,
		Msg:    "服务器错误，操作失败"}
}

func ResponseInternalServerErrorAndMsg(msg string) ApiResponse {
	return ApiResponse{
		Status: iris.StatusInternalServerError,
		Msg:    msg}
}

func ResponseBadRequest(msg string) ApiResponse {
	return ApiResponse{
		Status: iris.StatusBadRequest,
		Msg:    msg,
	}
}

func ResponseDataInvalid(data interface{}) ApiResponse {
	return ApiResponse{
		Status: iris.StatusBadRequest,
		Msg:    "数据验证失败",
		Data:   data,
	}
}

func Response(status int, msg string) ApiResponse {
	return ApiResponse{
		Status: status,
		Msg:    msg,
	}
}
